package io.kimmking;

import io.kimmking.spring01.Student;
import io.kimmking.spring02.Klass;
import io.kimmking.spring02.School;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

@ComponentScan("io.kimmking")
@Configuration
public class SchoolAutoConfiguration {

    @Bean(name="student100")
    public Student student(){
        return new Student();
    }

    @Bean
    public Klass klass(@Autowired @Qualifier("student100") Student s){
        Klass klass = new Klass();
        klass.setStudents(Arrays.asList(new Student[]{s}));
        return klass;
    }

    @Bean
    public School school(@Autowired Klass k, @Autowired @Qualifier("student100") Student s){
        School school = new School();
        school.setStudent100(s);
        school.setClass1(k);
        return school;
    }


}
